package com.lihao.sam.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lihao.sam.dao.ApartmentRepairedDao;
import com.lihao.sam.entity.ApartmentRepaired;
import com.lihao.sam.service.intf.ApartmentRepairedService;
import com.lihao.sam.vo.PageVo;
import com.lihao.sam.vo.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author Qinheyun
 * @Description:TODO
 */
@Service
public class ApartmentRepairedServiceImpl implements ApartmentRepairedService {
    @Resource
    private ApartmentRepairedDao dao;
    @Override
    public R add(ApartmentRepaired apartmentRepaired) {
        if (dao.add(apartmentRepaired)>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }

    @Override
    public R update(ApartmentRepaired apartmentRepaired) {
        if (dao.update(apartmentRepaired)>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }

    @Override
    public R del(int id) {
        if (dao.del(id)>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }

    @Override
    public PageVo all(String personApproval, Integer approval, int page, int limit) {
        PageHelper.startPage(page, limit);
        PageInfo<ApartmentRepaired> pageInfo = new PageInfo<>(dao.all(personApproval, approval));
        return PageVo.ok(pageInfo.getTotal(),pageInfo.getList());
    }
}
